<script>
function del_products(url){
	 if(!confirm('Bạn có chắc muốn xóa dữ liệu này?')){
         return;
      }
     	$.ajax({
	        url: url,
	        type: 'GET',
	        error: function(){
	            alert('Error !');
	        },
	        success: function(success)
	        {
                list_ajax('<?php echo $this->session->userdata('url_list_products');?>','');
  	        }
	    });
    }
</script>
<div class="topart">
    	<span class="left">
    		<font class="number">(<?php echo $this->products_model->get_count_all_products();?>)</font>
                    <a href="javascript:;">Sản phẩm</a>
                <font class="line">|</font>
                <font class="number">(<?php echo $this->products_model->get_count_all_products('yes');?>)</font>
                    <a href="javascript:;"><font color="#0b9901">Kích hoạt</font></a>
                <font class="line">|</font>
                <font class="number">(<?php echo $this->products_model->get_count_all_products('no');?>)</font>
                    <a href="javascript:;"><font color="#c60001">Chưa kích hoạt</font></a>
        </span>
        <span class="right1">
            <select id="limit" onchange="list_ajax('<?php echo base_url_admin('products/list_ajax/');?>')" style="width:50px;">
                    <option <?php if($limit == 5) echo 'selected="selected"';?> value="5">5</option>
                    <option <?php if($limit == 10) echo 'selected="selected"';?> value="10">10</option>
                    <option <?php if($limit == 20) echo 'selected="selected"';?> value="20">20</option>
                    <option <?php if($limit == 30) echo 'selected="selected"';?> value="30">30</option>
                    <option <?php if($limit == 50) echo 'selected="selected"';?> value="50">50</option>
                    <option <?php if($limit == 100) echo 'selected="selected"';?> value="100">100</option>
            </select>
            <div class="pagination">
                <?php echo $pagnav;?>
            </div>
        </span>

    </div>

<div class="tableout">
	<div class="title1">
            <div class="column" style="width:2%;"><input type="checkbox" name="check_all" value="" id="check_all" /></div>
            <div class="column" style="width:30%;">Tên sản phẩm</div>
            <div class="column" style="width:20%;">Mã sản phẩm</div>
            <div class="column" style="width:20%;">Loại điều hòa</div>
            <div class="column" style="width:15%;">Hãng sản xuất</div>                       
            <div class="column" style="width:10%;">Trạng thái</div>
        </div>
    
        <?php if($all_products):?>
        <?php
        $n = 0;
        foreach($all_products as $num => $pro):
          $n++;
          $next_order=$num;
          $back_order=$num;
          if($n>1){
          	$next_order = intval($num-1);
          }
          if($n==count($all_products)-1){
          	$back_order = intval($num+1);
          }
         ?>
	         <div class="linecate">
                    <div class="column" sttyle="width:2%;"><input type="checkbox" name="id[]" id="id[]" value="<?php echo $pro->id?>" /></div>
	            <div class="column" style="width:30%;" onmouseover="Hovercat('<?php echo $n?>')" onmouseout="Outcat('<?php echo $n?>')">
	            	<a class="art" href="javascript:void(0)" class="art" onclick ="load_form('<?php echo base_url_admin("products/view/".$pro->id);?>');document.getElementById('div_action').style.display='block';document.getElementById('fade').style.display='block'" title="<?php echo $pro->name;?>"><?php echo cut_string($pro->name,50)?></a><br />
	                <div class="action" id="neocat-<?php echo $n?>">
	                    <img src="<?php echo admin_img("edit.gif")?>" />
                            <a id="xxx<?php echo $pro->id;?>" href="javascript:void(0)" onclick ="edit(<?php echo $pro->id;?>);">Sửa</a>|
                            <?php if($pro->status=='no'){?>
	                      <img src="<?php echo admin_img("active.png")?>" class="png" /><a href="javascript:;" onclick="change_status('<?php echo base_url_admin("products/change_status")?>','yes',<?php echo $pro->id?>);">Kích hoạt</a>
	                      <?php }else{?>
	                      <img src="<?php echo admin_img("unactive.png")?>" class="png" /><a href="javascript:;" onclick="change_status('<?php echo base_url_admin("products/change_status")?>','no',<?php echo $pro->id?>);">Hủy kích hoạt</a>
	                     <?php }?>
	                     <img src="<?php echo admin_img("delete.gif")?>" class="png" /><a href="javascript:;" onclick="del_products('<?php echo base_url_admin("products/del/".$pro->id)?>');">Xóa</a>

	                </div>
	            </div>
               
               <div class="column" style="width:20%;">
                    <font style="color:#2195C8;"><?php echo cut_string($pro->code,30);?></font>
               </div>
               
               <div class="column" style="width:20%;">
                    <font style="color:#2195C8;"><?php echo cut_string($pro->product_type_name,30);?></font>
               </div>
                
               <div class="column" style="width:15%;">
                    <font style="color:#2195C8;"><?php echo cut_string($pro->company,30);?></font>
               </div>        
                          
	            <div class="column" style="width:10%;">
                    <?php if($pro->status=='yes'){?>
	                      <a href="javascript:;" onclick="change_status('<?php echo base_url_admin("products/change_status")?>','no',<?php echo $pro->id?>);"><img src="<?php echo admin_img("active.png")?>" class="png" /></a>
	                      <?php }else{?>
	                      <a href="javascript:;" onclick="change_status('<?php echo base_url_admin("products/change_status")?>','yes',<?php echo $pro->id?>);"><img src="<?php echo admin_img("unactive.png")?>" class="png" /></a>
	            <?php }?>
	            </div>
	        </div>        
        <input type="hidden" name="lib[<?php echo $num?>][id]" value="<?php echo $pro->id?>" />               
        <?php endforeach; echo "</div>"; //last div close ?>
         <?php else:?>
        <div class="linecate2">
        	<b>Dữ liệu hiện tại đang rỗng!</b>
        </div>
        <?php endif;?>
        </form>
        <span class="right1">
            <div class="pagination">
                   <?php echo $pagnav;?>
            </div>
        </span>
    </div>
</div>
</form><!-- End form action -->
<div id="div_action" class="white_content"><!-- Content action ajax --></div>
<div id="fade" class="black_overlay"></div>
